import http from "@/assets/js/http";

const name = "Department"
const dir = "auth"
export default {
    urlFind: '/' + dir + '/admin/' + name + '/info',
    urlFindToEdit: '/' + dir + '/admin/' + name + '/get',
    urlFindBy: '/' + dir + '/admin/' + name + '/list',
    urlSave: '/' + dir + '/admin/' + name + '/save',
    urlDelete: '/' + dir + '/admin/' + name + '/delete',
    urlDeleteAll: '/' + dir + '/admin/' + name + '/delete_many',
    urlCopy: '/' + dir + '/admin/' + name + '/copy',
    urlEditMany: '/' + dir + '/admin/' + name + '/edit_many',
    urlTree: '/' + dir + '/admin/' + name + '/tree',
    urlChoice: '/' + dir + '/admin/' + name + '/choice',
    find(id, func) {
        http.get(this.urlFind, {id}, res => {
            func(res)
        })
    },
    findToEdit(id, func) {
        http.post(this.urlFindToEdit, {id}, res => {
            func(res)
        })
    },
    findBy(param, func) {
        http.post(this.urlFindBy, param, res => {
            func(res.data.lists, res.data.query)
        })
    },
    save(data, func) {
        http.post(this.urlSave, data, res => {
            func(res)
        })
    },
    delete(id, func) {
        http.post(this.urlDelete, {id}, res => {
            func(res)
        })
    },
    deleteAll(ids, func) {
        http.post(this.urlDeleteAll, {ids}, res => {
            func(res)
        })
    },
    copy(ids, func) {
        http.post(this.urlCopy, {ids}, res => {
            func(res)
        })
    },
    editMany(ids, data, func) {
        http.post(this.urlEditMany, {
            ids,
            _action: data
        }, res => {
            func(res)
        })
    },
}